package littlecyberwar;

import javax.swing.ImageIcon;
import javax.swing.UIManager;
import javax.swing.*; 
import java.awt.*;
import littlecyberwar.ui.*;
import ModuleBuilder.*;

public class test {
  boolean packFrame = false;

  /**Construct the application*/
  public test() {
  	// first let's put up a invisible frame, which is used to put up a Dialog
  	JFrame frame = new JFrame("App Launcher");
	ImageIcon ic = new ImageIcon(littlecyberwar.ui.MainFrame.class.getResource("LCWFrameIcon.gif"));

  	// construct a dialog that let the user to pick 1) launch player, or 2) Builder
  	Object[] options = {"Game Player",
            "Scenario Builder"};
	int n = JOptionPane.showOptionDialog(frame,
		"Which program would you like to launch?",
		"Welcome to Little Cyber Wars",
		JOptionPane.YES_NO_OPTION,
		JOptionPane.QUESTION_MESSAGE,
		ic,
		options,
		options[0]);
	
	if (n == JOptionPane.YES_OPTION) {
  	
	    frame = new MainFrame();
	    //Validate frames that have preset sizes
	    //Pack frames that have useful preferred size info, e.g. from their layout
	} else {
		frame = new ModuleBuilderMain();
	}
    if (packFrame) {
      frame.pack();
    }
    else {
      frame.validate();
    }
    //Center the window
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = frame.getSize();
    int h = (int)(screenSize.height * 0.8);
    int w = (int)(screenSize.width * 0.8);
	frameSize.height = h;
	frameSize.width = w;
	frame.setSize(w,h);
	frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
    frame.setVisible(true);
    return;	
  }
  
  /**Main method*/
  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }
    catch(Exception e) {
      e.printStackTrace();
    }
    new test();
  }
}